﻿using PLCS.Application.Contracts.SolutionApp.Dtos;

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace PLCS.App.ProcessSolution.Convert
{
    internal class SolutionStepsConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is List<SolutionStepDto> solutionSteps)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < solutionSteps.Count; i++)
                {
                    sb.Append($"第【{i + 1}】步：{solutionSteps[i].Process.Replace(ConstantChar.SplitChar, '/')}");
                    if (i < solutionSteps.Count - 1)
                        sb.Append(ConstantChar.SplitChar);
                }
                return sb.ToString();
            }
            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}